Notifications
Facilitates sending, managing, and processing course invitations, leveraging role-based permissions and SMTP for reliable email delivery.
🗂️ Folder Structure
notifications/
├── controllers/
│ └── InviteController.ts # Endpoints to create, view, process, resend, and cancel invites
├── services/
│ ├── InviteService.ts # Business logic for invite lifecycle and persistence
│ └── MailService.ts # Composes and sends invitation emails via SMTP
├── classes/
│ └── validators/ # DTOs for invite creation and processing
├── abilities/ # CASL policies for invite permissions
├── types.ts # Inversify DI tokens
└── container.ts # Binds controllers, services, and repositories
🎯 Core Responsibilities
- Invitation Generation: Validates roles and course context, then issues unique invite tokens linked to courseId and versionId.
- Email Delivery:
MailServiceformats HTML emails using configurable templates and sends via SMTP (using Nodemailer). - Invite Processing: Web endpoint renders a redirect page or JSON response upon token consumption, guiding users to enrollment flows.
- Resend & Cancel: Allows authorized users to resend pending invites or revoke them, updating invite status accordingly.
- Permission Enforcement: Uses CASL abilities to ensure only permitted roles (e.g., instructors, TAs) can invite, view, or manage invites.
🔁 Workflow
- Create Invites: Authorized user submits a list of email addresses and roles;
InviteControllerdelegates toInviteService. - Persist Invites:
InviteServicegenerates tokens, saves invite records viaInviteRepository, and callsMailServiceto send emails. - Process Invitations: Recipients click invite links;
InviteController.processInvitesvalidates token, marks it consumed, and redirects to the front-end enrollment page. - Manage Invites: Instructors can view all invites for a course version, resend emails, or cancel pending invitations through dedicated endpoints.